package com.huatai.dataservice.fire.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huatai.dataservice.domain.TbFireSafetyHazardRecord;
import com.huatai.dataservice.fire.service.TbFireSafetyHazardRecordService;
import com.huatai.dataservice.fire.mapper.TbFireSafetyHazardRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author htzy
* @description 针对表【tb_fire_safety_hazard_record(消防安全隐患记录表)】的数据库操作Service实现
* @createDate 2025-06-05 15:34:47
*/
@Service
public class TbFireSafetyHazardRecordServiceImpl extends ServiceImpl<TbFireSafetyHazardRecordMapper, TbFireSafetyHazardRecord>
    implements TbFireSafetyHazardRecordService{

    @Autowired
    private TbFireSafetyHazardRecordMapper tbFireSafetyHazardRecordMapper;


    /***
     * @author gaowengui
     * 通过className -> majorClass
     * @param className
     * @return
     */
    @Override
    public List<TbFireSafetyHazardRecord> selectByClassName(String className) {
        String majorClassName = "";
        LambdaQueryWrapper<TbFireSafetyHazardRecord> queryWrapper = Wrappers.lambdaQuery();
        if ("electric".equals(className)){
            majorClassName = "用电隐患告警";
        }
        else if ("water".equals(className)){
            majorClassName = "用水隐患告警";
        }
        else if ("host".equals(className)){
            majorClassName = "主机告警";
        }
        queryWrapper.eq(TbFireSafetyHazardRecord::getMajorclass,majorClassName);
        return tbFireSafetyHazardRecordMapper.selectList(queryWrapper);
    }

    @Override
    public List<TbFireSafetyHazardRecord> selectAll() {
        List<TbFireSafetyHazardRecord> tbFireSafetyHazardRecordList = tbFireSafetyHazardRecordMapper.selectAll();
        return  tbFireSafetyHazardRecordList;
    }
}




